﻿using System;

namespace negoserverjni
{
    //unsafe public delegate char* GetStringChars(IntPtr env, IntPtr javastring, bool* b);
    //unsafe public delegate void ReleaseStringChars(IntPtr env, IntPtr javastring, char* chars);
    /// Return Type: jchar*
    ///env: JNIEnv*
    ///string: jstring->jobject->_jobject*
    ///isCopy: jboolean*
    //[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
    //unsafe public delegate char* GetStringCritical(IntPtr env, IntPtr javastring, bool* isCopy);

    /// Return Type: void
    ///env: JNIEnv*
    ///string: jstring->jobject->_jobject*
    ///cstring: jchar*
    //[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
    //unsafe public delegate void ReleaseStringCritical(IntPtr env, IntPtr javastring, char* cstring);

    unsafe public delegate IntPtr NewByteArray(IntPtr env, int jsize);
    unsafe public delegate IntPtr NewCharArray(IntPtr env, int jsize);
    unsafe public delegate void SetByteArrayRegion(IntPtr env, IntPtr jarray, int position, int length, byte* c_array);
    unsafe public delegate void SetCharArrayRegion(IntPtr env, IntPtr jarray, int position, int length, char* c_array);
    unsafe public delegate int RegisterNatives(IntPtr env, IntPtr clazz, JNINativeMethod* methods, int nMethods);
    /// Return Type: jstring->jobject->_jobject*
    ///env: JNIEnv*
    ///unicode: jchar*
    ///len: jsize->jint->int
    [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
    unsafe public delegate IntPtr NewString(IntPtr env, char* unicode, int len);

    /// Return Type: void*
    ///env: JNIEnv*
    ///array: jarray->jobject->_jobject*
    ///isCopy: jboolean*
    //[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
    //unsafe public delegate IntPtr GetPrimitiveArrayCritical(IntPtr env, IntPtr array, bool* isCopy);

    /// Return Type: void
    ///env: JNIEnv*
    ///array: jarray->jobject->_jobject*
    ///carray: void*
    ///mode: jint->int
    //[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
    //public delegate void ReleasePrimitiveArrayCritical(IntPtr env, IntPtr array, IntPtr carray, int mode);
    public delegate int GetArrayLength(IntPtr env, IntPtr javaarray);
    unsafe public delegate IntPtr GetByteArrayElements(IntPtr env, System.IntPtr jarray, bool* isCopy);

    /// Return Type: void
    ///env: JNIEnv*
    ///array: jbyteArray->jarray->jobject->_jobject*
    ///start: jsize->jint->int
    ///len: jsize->jint->int
    ///buf: jbyte*
    [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
    unsafe public delegate void GetByteArrayRegion(IntPtr env, IntPtr array, int start, int len, byte* buf);
    /// Return Type: jsize->jint->int
    ///env: JNIEnv*
    ///str: jstring->jobject->_jobject*
    [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
    public delegate int GetStringLength(IntPtr env, IntPtr jstring);
    /// Return Type: void
    ///env: JNIEnv*
    ///str: jstring->jobject->_jobject*
    ///start: jsize->jint->int
    ///len: jsize->jint->int
    ///buf: jchar*
    [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
    unsafe public delegate void GetStringRegion(IntPtr env, IntPtr javastr, int start, int len, IntPtr buf);
    unsafe public delegate IntPtr GetObjectArrayElement(IntPtr env, IntPtr array, int index);
    unsafe public delegate IntPtr SetObjectArrayElement(IntPtr env, IntPtr jobjectArray, int index, IntPtr element);
    unsafe public delegate IntPtr NewBooleanArray(IntPtr env, int len);
    unsafe public delegate void SetBooleanArrayRegion(IntPtr env, IntPtr jbooleanArray, int start, int l, bool* buf);
    unsafe public delegate void SetLongArrayRegion(IntPtr env, IntPtr jlongArray, int start, int len, long* buf);

    //unsafe public delegate int RegisterNatives(IntPtr env, IntPtr classz, IntPtr methods, int nbMethods);

    public delegate IntPtr StringtoArray_delegate(IntPtr env, IntPtr classz, IntPtr javastring);
    public delegate IntPtr TranslateNameIntoSid_delegate(IntPtr env, IntPtr calssz, IntPtr sidInBytes);
    public delegate IntPtr TranslateSidIntoName_delegate(IntPtr env, IntPtr classz, IntPtr javaName);
    public delegate int Accept_sec_delegate(IntPtr env, IntPtr classz, IntPtr jtoken, IntPtr jtoken_out, long authL, IntPtr authl_out, IntPtr name_out, IntPtr sids, IntPtr presents_out, IntPtr authenticationType_out); 
    public delegate void FreeAuthenticator_delegate(IntPtr env, IntPtr classz, long handleSpnego);
    public delegate int Login_delegate(IntPtr env, IntPtr classz, IntPtr jname, IntPtr jpassword, IntPtr jnom_out, IntPtr jsids, IntPtr jpresents_out);
}
